$dir = '/data1/bsi/BORA_processing/devel/eqtl/parallelize_genotypingsurvival/Matrix_eQTL_R_Source';
$files= `ls $dir/results_permutation_onlyids/`;
@files = split("\n",$files);
system("mkdir $dir/merged_premutation_manual_lm");
for($i=0;$i<@files;$i++)
{
	print "$files[$i]\n";
	open(WRBUFF,">./merged_premutation_manual_lm/$files[$i]") or die "not able to write file $files[$i]";
	$files[$i] =~ s/\.txt//g;
	for($y=1;$y<30;$y++)
	{
		$file = "./results_permutation_manual_glm/result_"."$y"."_$files[$i]".'.txt';
		open BUFF,"$file" or die "no file exists $file\n";
		$line = <BUFF>;
		if($y==1)
		{
			print WRBUFF $line;
		}
		while($line = <BUFF>)
		{
			print WRBUFF $line;
		}
	}	
}
